<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title></title>
	<script src="/others/jquery-2.1.4/jquery.min.js"></script>
</head>
<body>
	<div class="heading">
		<p><h3>登陆登录<h3></p>
	</div>
	<div class="bodying">
		<form id="login" action="/app/user/login" method="post">
		    <input class="input" type="text" value="" name="username" placeholder="请输入您的账户">
		    <p><input class="p_input" type="password" value="" name="password" placeholder="请输入密码"></p>
			<button type="button"  onclick="login1()">登陆</button>
			<button type="button" onclick="javascrtpt:window.location.href='./create.html'">注册</button>
			<button type="button" onclick="javascrtpt:window.location.href='./select.html'">忘记密码</button>
		</form>
	</div>
	<script type="text/javascript">
		var login1=function(){
			var form=document.getElementById("login")
			var username=form.username.value
			var psw=form.password.value
			if(username==""){
				alert("账号不能为空")
			}
			else if(psw==""){
				alert("密码不能为空")
			}
			else if(username.length>20||psw.length>20){
				alert("账号或密码长度过长")
			}
			else {//进行提交
				var url=form.action.valueOf()
				var method=form.method.valueOf()
				url+="?username="+username+"&password="+psw
				var headers
				//url = "http://hacker.eachma.com/app/user/login?username=huzhen189&password=583330928"
				xmlHttp=new XMLHttpRequest();
				xmlHttp.onreadystatechange = function(){
					var res = xmlHttp.responseText
						console.log(res)
					//window.location.href="/index.html"
				}
				if (xmlHttp!=null) {
					xmlHttp.open(method, url,true);
					xmlHttp.send(null);
				}
			}
		}
	</script>
</body>
</html>